<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
<h1>首页</h1>
  <a href="/bmi.html">BMI身体质量指数测试</a>
  <input type="button" value="发送get请求" @click="f1()">
    <hr>
    <input type="text" v-model="emp.name" placeholder="姓名" >
    <input type="text" v-model="emp.salary" placeholder="工资">
    <input type="text" v-model="emp.job" placeholder="工作">
    <input type="button" value="发送post请求" @click="f2()">

</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>

<script>
    let v= new Vue({
        el:"body>div",
        data:{
        emp:{
            name:"",salary:"",job:""
        }
        },
      methods:{
          f1(){
            //发送异步请求
            axios.get("/helloAxios?info=tom").then(function (response){
              //服务器响应的数据
              alert(response.data);
            })
          },
          f2(){
              //发送post请求并且把和页面进行绑定的员工对象里面的数据提交
              axios.post("/helloPost",v.emp).then(function (response){
                  //服务器响应的数据
                  alert(response.data);
              })
          }
      }
    })
</script>
</body>
</html>